{% extends 'partial/layout.njk' %}

{% block body %}
  <header class='demos-header'>
    <a href="/">
      <h1 class="demos-title">成员列表</h1>
    </a>
  </header>

  {% set orgPrev = 0 %}
  {% set orgCurr = memberTree[0].orgId %}

  <div class="weui-btn-area">
    <a id="toggle-all" class="weui-btn weui-btn_default">显示已删除人员</a>
  </div>
  <div class="bd">
    <div class="page__bd">
        {% set orgPrev = memberTree[0].orgId %}

        {% for member in memberTree %}
  
          {% if loop.first %}
            <div class="weui-cells__title" style="margin-left: {{ 12*member._levelNo }}px">
              {{ member._orgName }}
              ({{ member._count }}人)
            </div>
            <div class="weui-cells">
            {% endif %}
  
            {% if member.orgId != orgPrev %}
              {% set orgPrev = member.orgId %}
            </div>
            <div class="weui-cells__title" style="margin-left: {{ 12*member._levelNo }}px">
              {{ member._orgName }}
              ({{ member._count }}人)
            </div>
            <div class="weui-cells">
            {% endif %}
  
            <a
              class="weui-cell weui-cell_access {% if member.joinState != 1 %} delete-member {% endif %}"
              style="margin-left: {{ 12*member._levelNo }}px;
                    {% if member.joinState != 1 %} display:none {% endif %}"
              href="/page/taskList?id={{ member.id }}">
              <div class="weui-cell__bd">
                <p>{{ member.netName}}
                  {{ member.position }}</p>
              </div>
              <div class="weui-cell__ft">
                {% if member._countCommented %}
                  {{ member._countCommented }}
                {% else %}
                  0
                {% endif %}/
                {% if member._countTask %}
                  {{ member._countTask }}
                {% else %}
                  0
                {% endif %}
              </div>
            </a>
  
            {% if loop.last %}
            </div>
          {% endif %}
  
        {% endfor %}
    </div>
  </div>
{% endblock %}

{% block script %}

  <style>
    .delete-member {
      color: #f76260;
    }
  </style>

  <script>
    $('#toggle-all').on('click', function (event) {
      $('.delete-member').toggle();
    });
  </script>

{% endblock %}